let hookStates = [];
let hookIndex = 0;
let scheduleUpdate;
export function useLayoutEffect(callback, dependencies) {
  let currentIndex = hookIndex;
  if (hookStates[hookIndex]) {
    let [destroy, lastDeps] = hookStates[hookIndex];
    let same = dependencies && dependencies.every((item, index) => item === lastDeps[index]);
    if (same) {
      hookIndex++;
    } else {
      destroy && destroy();
      queueMicrotask(() => { // 加入到微任务队列
        hookStates[currentIndex] = [callback(), dependencies];
      });
      hookIndex++
    }
  } else {
    queueMicrotask(() => {
      hookStates[currentIndex] = [callback(), dependencies];
    });
    hookIndex++;
  }
}
export function useRef(initialState) {
  hookStates[hookIndex] = hookStates[hookIndex] || { current: initialState };
  return hookStates[hookIndex++];
}